package logic;

import java.util.Calendar;

import dataAccess.TicketDB;
import exception.MyException;

public class Ticket {
	
	private int idTicket;
	private Calendar from;
	private int duration;
	private Calendar saleDate;
	private State state;
	private int idCancellation;
	private String plate;
	private Agency agency;
		
	public enum State {
		active, pasive;
	}
	
	public Ticket(int idTicket, Calendar from, int duration, Calendar date,
			State state, int idCancellation, String plate, Agency agency) {
		super();
		this.idTicket = idTicket;
		this.from = from;
		this.duration = duration;
		this.saleDate = date;
		this.state = state;
		this.idCancellation = idCancellation;
		this.plate = plate;
		this.agency = agency;
	}

	public int getIdTicket() {
		return idTicket;
	}

	public void setIdTicket(int idTicket) {
		this.idTicket = idTicket;
	}

	public Calendar getFrom() {
		return from;
	}

	public void setFrom(Calendar from) {
		this.from = from;
	}

	public int getDuration() {
		return duration;
	}

	public void setDuration(int duration) {
		this.duration = duration;
	}

	public Calendar getSaleDate() {
		return saleDate;
	}

	public void setSaleDate(Calendar saleDate) {
		this.saleDate = saleDate;
	}

	public State getState() {
		return state;
	}

	public void setState(State state) {
		this.state = state;
	}

	public int getIdCancellation() {
		return idCancellation;
	}

	public void setIdCancellation(int idCancellation) {
		this.idCancellation = idCancellation;
	}

	public String getPlate() {
		return plate;
	}

	public void setPlate(String plate) {
		this.plate = plate;
	}

	public Agency getAgency() {
		return agency;
	}

	public void setAgency(Agency agency) {
		this.agency = agency;
	}

	/**
	 * Methods
	 * @throws MyException 
	 */	
	public void save(double rate) throws MyException{	
		TicketDB ticketDB = new TicketDB();
		ticketDB.save(this, rate);		
	}
	
	public boolean validate(int idTicket){
		
		return false;
	}
		
	public boolean auxValidate(){
		
		return true;
	}
	
	/**
	 * Funciones para 2da entrega
	 */
	public void deleteTicket(int idAnul){		
		
	}
	
}
